// pages/x_audio/x_audio.js
const InnerAudioContext = wx.createInnerAudioContext()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    src:'',
    isplay:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setInnerAudioOption({
      mixWithOther:false
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady:function(e){
    this.audioCtx = wx.createAudioContext('myAudio')
    this.audioCtx.setSrc('http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46')
    this.audioCtx.play()

    
    InnerAudioContext.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46'
    InnerAudioContext.startTime=0
    InnerAudioContext.autoplay=false
    InnerAudioContext.loop = false
    InnerAudioContext.obeyMuteSwitch=true
    InnerAudioContext.volume=0.3
    const progress = InnerAudioContext.duration
    const nowpoint = InnerAudioContext.currentTime
    InnerAudioContext.paused
    InnerAudioContext.buffered
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    InnerAudioContext.stop()
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    InnerAudioContext.destroy()
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  audioPlay(){
    this.audioCtx.play()
  },
  audioPause(){
    this.audioCtx.pause()
  },
  audio14(){
    this.audioCtx.seek(60)
  },
  audioStart(){
    this.audioCtx.seek(0)
  }, 
  play: function () { InnerAudioContext.play(); console.log(InnerAudioContext.duration); this.setData({ isplay: true }); }, 
  // 停止 
  stop: function () { InnerAudioContext.pause(); this.setData({ isplay: false }); }

})